package day07.ThreadDemo;

/*
 * Author: JacksonCoder
 * FileName: CallableDemo
 * Version: 1.0.0
 * Date: 2025/4/14
 */

import java.util.concurrent.*;

public class CallableDemo {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService executor = Executors.newSingleThreadExecutor();

        Callable<String> task = () -> "Hello from Callable";
        Future<String> future = executor.submit(task);

        System.out.println("Result: " + future.get()); // 阻塞直到任务完成并获取结果
        executor.shutdown();

    }

}
